<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body {
            background-image: url(./images/001.jpg);
        }

        ul {
            width: 888px;
            height: 100px;
            margin: 100px auto;
        }

        li {
            list-style: none;
            float: left;
            width: 200px;
            height: 100px;
            /* padding: 10px; */
            background-color: #fff;
        }

        li img {
            width: 100%;
            height: 100%;
        }
    </style>
</head>

<body>
    <ul>
        <li><img src="./images/001.jpg" alt=""></li>
        <li><img src="./images/002.jpg" alt=""></li>
        <li><img src="./images/003.jpg" alt=""></li>
        <li><img src="./images/004.jpg" alt=""></li>
    </ul>

    <script>
        var imgs = document.querySelectorAll('ul li img');
        for (var i = 0; i < imgs.length; i++) {
            imgs[i].onclick = function () {
                var filename = this.src;
                console.log(filename);
                document.body.style.backgroundImage = 'url(' + filename + ')';
            }
        }
    </script>
</body>

</html>